$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'onlinestudy/xcbm/studyStatistics',
        datatype: "json",
        mtype:"post",
        postData:{"bmlx":bmlx},
        colModel: [
			{ label: '学习地点', name: 'deptname', index: 'deptname', width: 80 },
			{ label: '未学完课程', name: 'wxw', index: 'wxw', width: 130 },
			{ label: '已学完', name: 'xw', index: 'xw', width: 100 },
			{ label: '未审核', name: 'wsh', index: 'wsh', width: 80 },
			{ label: '通过', name: 'tg', index: 'tg', width: 60},
			{ label: '不通过', name: 'wtg', index: 'wtg', width: 60},
			{ label: '合计', name: 'zs', index: 'zs', width: 120}
        ],
		viewrecords: true,
        height: 290,
        rowNum: 100,
		rowList : [100],
        rownumbers: true,
        rownumWidth: 25,
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        footerrow:true,
        gridComplete:function(){
            var xwtotal = $("#jqGrid").getCol("xw", false, 'sum');
            var wxwtotal = $("#jqGrid").getCol("wxw", false, 'sum');
            var wshtotal = $("#jqGrid").getCol("wsh", false, 'sum');
            var tgtotal = $("#jqGrid").getCol("tg", false, 'sum');
            var wtgtotal = $("#jqGrid").getCol("wtg", false, 'sum');
            var total = $("#jqGrid").getCol("zs", false, "sum");
            $("#jqGrid").footerData('set', {
                "deptname": "合计",
                "wxw": wxwtotal,
                "xw": xwtotal,
                "wsh": wshtotal,
                "tg": tgtotal,
                "wtg": wtgtotal,
                "zs": total
            });
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
});

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		title: null,
		xcBm: {"bmlx":bmlx}
	},
    mounted:function(){
	    this.dateDefault();
    },
	methods: {
		query: function () {
			vm.reload();
		},
		reload: function (event) {
			vm.showList = true;
			var page = $("#jqGrid").jqGrid('getGridParam','page');
            var postData = $("#jqGrid").jqGrid("getGridParam", "postData");
            $.each(postData, function (k, v) {
                delete postData[k];
            });
            var paras = {
                bmlx:vm.xcBm.bmlx,
                ldate_start:$("#ldate_start").val() == ""?undefined:$("#ldate_start").val(),
                ldate_end:$("#ldate_end").val() == ""?undefined:$("#ldate_end").val(),
            };
			$("#jqGrid").jqGrid('setGridParam',{
                page:page,
                postData:paras
            }).trigger("reloadGrid");
		},
        dateDefault:function(){
            //初始化日期范围组件
            $('#datepicker_range input').datepicker({
                language: 'zh-CN',//显示中文
                startView: 0, //选择器开始界面 0：天（默认 1：月2：年3：十年 4：世纪
                minViewMode: 0,//最小选择精度 0：天（最小默认）
                maxViewMode: 2, //最大选择精度 4：世纪（最大默认）
                format: 'yyyy-mm-dd',//显示格式
                minView: "day",//设置只显示到月份
                // initialDate: new Date(),
                autoclose: true,//选中自动关闭
                // todayBtn: true//显示今日按钮
                clearBtn: true, //清除按钮
                todayHighlight: true //今日高亮
            });
        },
	}
});